
/*
 * ****************************
 * Eric Doherty
 * Jesse Kinney
 * 
 * TCSS 422 Scheduler simulator
 * Interrupt Class
 * 
 * 6/4/08
 * ****************************
 */

public class Interrupt implements Comparable<Interrupt>
{
  private int timeToProcess;

  private Event.EventTypes eventType;

  private int priority;

  public Interrupt(int priority)
  {
    this.priority = priority;
    eventType = null;
    timeToProcess = (int) (Math.random() * 40 + 10);
  }

  public Interrupt(int priority, Event.EventTypes eventType)
  {
    this.priority = priority;
    this.eventType = eventType;
    timeToProcess = (int) (Math.random() * 40 + 10);
  }

  public Event.EventTypes getEventType()
  {
    return eventType;
  }

  public int getTimeToProcess()
  {
    return timeToProcess;
  }

  public int getPriority()
  {
    return priority;
  }

  public int compareTo(Interrupt interrupt)
  {
    int result = 0;

    if (interrupt.getPriority() > priority)
      result = 1;
    else if (interrupt.getPriority() < priority)
      result = -1;

    return result;
  }
}
